package com.wwj.study.singleton.lazy;

import com.wwj.study.singleton.hungry.Hungry;

import java.util.concurrent.CountDownLatch;

/**
 * Created by lenovo on 2018/11/15.
 */
public class LazyOneTest {

    public static void main(String[] args) {

        long start = System.currentTimeMillis();
        System.out.println("开始时间：" + start);
        int count = 10000;
        final CountDownLatch countDownLatch = new CountDownLatch(count);

        for (int i = 0; i < count; i++) {
            new Thread() {
                @Override
                public void run() {

                    try {
                        countDownLatch.await();
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }

                    LazyOne obj = LazyOne.getInstance();
//                    System.out.println(System.currentTimeMillis() + "对象地址：" + obj);
                }
            }.start();

            countDownLatch.countDown();
        }

        long end = System.currentTimeMillis();
        System.out.println("结束时间：" + end);

        System.out.println("耗时：" + (end - start));
    }
}
